﻿
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
using System.Data.SqlClient;
using DevExpress.XtraReports.UI;
using prjKQXS_DLL;
using prjKQXS_DLL.LoTo;
using prjKQXS_Report.Loto;

namespace prjKQXS_UI.Lo_to
{
    public partial class frmInBaocaoTH : DevExpress.XtraEditors.XtraForm
    {
        public frmInBaocaoTH()
        {
            InitializeComponent();
        }

        private void frmThDTDuThuong_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            deNgaythang.DateTime = DateTime.Now;
            Loaddonvi();
            marqueeProgressBarControl1.Properties.Stopped = true;
        }

        private void Loaddonvi()
        {
            try
            {
                SqlConnection conn = new SqlConnection(BienTc.connString);
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                SqlDataAdapter da = new SqlDataAdapter("Select * from DMDONVI Where isPublic=1", conn);
                DataTable dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    lueDonvi.Properties.DataSource = dt;
                    lueDonvi.ItemIndex = 0;
                }

            }
            catch
            {
                
            }
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnTonghop_Click(object sender, EventArgs e)
        {

                  prjKQXS_Report.rptTongHopDTCanBo frm = new prjKQXS_Report.rptTongHopDTCanBo
                {
                    madv = lueDonvi.GetColumnValue("Ma_DT").ToString(),
                    tendv = lueDonvi.GetColumnValue("Ten_DT").ToString()
                    
                };
               
            frm.dtSource = clsLoTo.getdataReportTongHopDTCanBo(frm.madv, DateTime.Now);
            frm.ShowRibbonPreviewDialog();
        }

        private void btnChitiet_Click(object sender, EventArgs e)
        {
            string madv = lueDonvi.GetColumnValue("Ma_DT").ToString();
            string tendv = lueDonvi.GetColumnValue("Ten_DT").ToString();
            rptTHDTDaiLy rpt1 = new rptTHDTDaiLy
                {
                    ma_dv = String.IsNullOrEmpty(madv) ? null : madv.Substring(0, 1),
                    ten_dv = tendv.ToString().Trim()
                };
                rpt1.dtSuorce1 = clsLoTo.getdataReportTHDTDaiLy(rpt1.ma_dv, DateTime.Now);
                rpt1.ShowRibbonPreviewDialog();
        }

       }
}